//
//  Square.swift
//  TakePhoto
//
//  Created by 李雷川 on 2017/3/22.
//  Copyright © 2017年 李雷川. All rights reserved.
//

import UIKit
import FZSFCommonTools
public class Square: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.clear
    }
    
    required public init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override public func draw(_ rect: CGRect) {
        

        let context = UIGraphicsGetCurrentContext()
        
        
        let lineWidth:CGFloat = 20
        let lineHeight:CGFloat = 20
        context?.setStrokeColor(UIColor.white.cgColor)
        context?.setLineWidth(2)
        context?.stroke(bounds)
        
        
        
        context?.setStrokeColor(AppColors.highlight.cgColor)
        context?.setLineWidth(4)
        context?.beginPath()
        
        context?.move(to: CGPoint(x: 0, y: 0))
        context?.addLine(to: CGPoint(x: lineWidth, y: 0))
        context?.strokePath()
        context?.move(to: CGPoint(x: 0, y: 0))
        context?.addLine(to: CGPoint(x: 0, y: lineHeight))
        context?.strokePath()
        
        context?.move(to: CGPoint(x: rect.maxX - lineWidth, y: 0))
        context?.addLine(to: CGPoint(x: rect.maxX, y: 0))
        context?.strokePath()
        context?.move(to: CGPoint(x: rect.maxX, y: 0))
        context?.addLine(to: CGPoint(x: rect.maxX, y: lineHeight))
        context?.strokePath()
        
        
        context?.move(to: CGPoint(x: 0, y: rect.maxY - lineHeight))
        context?.addLine(to: CGPoint(x: 0, y: rect.maxY))
        context?.strokePath()
        context?.move(to: CGPoint(x: 0, y: rect.maxY))
        context?.addLine(to: CGPoint(x: lineWidth, y: rect.maxY))
        context?.strokePath()
        
        
        context?.move(to: CGPoint(x: rect.maxX - lineWidth, y: rect.maxY))
        context?.addLine(to: CGPoint(x: rect.maxX, y: rect.maxY))
        context?.strokePath()
        context?.move(to: CGPoint(x: rect.maxX, y: rect.maxY))
        context?.addLine(to: CGPoint(x: rect.maxY, y: rect.maxY - lineHeight))
        context?.strokePath()
        
    }
    

}
